package com.highcom.controller;

import com.highcom.bean.User;
import com.highcom.exception.UserTooManyException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.List;

@Controller
public class TableController {

    @GetMapping("/basic_table")
    public String basic_table(){
        int i = 1/0;
        System.out.println("i = " + i);
        return "table/basic_table.html";
    }

    @GetMapping("/dynamic_table")
    public String dynamic_table(Model model){
        //创建一个List<User>   lilei  123
        List<User> list = Arrays.asList(new User("tom","123456"),
                 new User("lilei","123123"),
                 new User("hmm","111111"),
                 new User("gaohui","333333"));
        if(list.size() > 3){
            throw  new UserTooManyException();
        }

        model.addAttribute("users",list);
        return "table/dynamic_table.html";
    }
    @GetMapping("/responsive_table")
    public String responsive_table(){
        return "table/responsive_table.html";
    }
    @GetMapping("/editable_table")
    public String editable_table(){
        return "table/editable_table.html";
    }


}
